package com.laamella.syntherface.synths.models;

import java.util.List;

import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;

@SuppressWarnings("serial") public abstract class ListTableModel<T> extends AbstractTableModel {
	private List<T> model;

	public ListTableModel(List<T> model) {
		this.model = model;
	}

	@Override public int getRowCount() {
		return model.size();
	}

	@Override public Object getValueAt(int row, int column) {
		return getValueFrom(model.get(row), column);
	}

	public abstract Object getValueFrom(T item, int column);

	public abstract String[] getColumnNames();

	@Override public String getColumnName(int column) {
		return getColumnNames()[column];
	}

	@Override public int getColumnCount() {
		return getColumnNames().length;
	}
}
